package com.usian.vo;

import lombok.Getter;

/**
 * @author zqtao
 */
@Getter
public class Result<T> {


    // Getters 和 Setters
    private int code; // 状态码
    private String message; // 消息
    private T data; // 数据

    private String token;

    public Result() {}

    public Result(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Result(int code, String message,String token, T data) {
        this.code = code;
        this.message = message;
        this.token = token;
        this.data = data;
    }

    public static <T> Result<T> success() {
        return new Result<>(200, "Success", null);
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(200, "Success", data);
    }
    public static <T> Result<T> successToken(String token,T data) {
        return new Result<>(200, "Success",token,data);
    }

    public static <T> Result<T> error(String message) {
        return new Result<>(500, message, null);
    }
    public static <T> Result<T> error() {
        return new Result<>(500,"error", null);
    }

    public void setCode(int code) { this.code = code; }

    public void setMessage(String message) { this.message = message; }

    public void setData(T data) { this.data = data; }




}
